home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Sample Code / System 7.0 Samples / INIT - CDEV / SAGlobals.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-18  |  1.7 KB  |  57 lines  |  [TEXT/MPS ]

  1. /*------------------------------------------------------------------------------
  2. #
  3. #    Macintosh Developer Technical Support
  4. #
  5. #    Sample Control Panel Device and INIT Combination
  6. #
  7. #    Program:    INIT - CDEV
  8. #    File:        SAGlobals.c    -    C Source
  9. #
  10. #    Copyright © 1990 Apple Computer, Inc.
  11. #    All rights reserved.
  12. #
  13. ------------------------------------------------------------------------------*/
  14.  
  15. #include <Memory.h>
  16. #include <OSUtils.h>
  17. #include <SAGlobals.h>
  18.  
  19. #define kAppParmsSize 32
  20.  
  21. /*
  22.     !!! NOTE !!!
  23.  
  24.     These routines are used to implement global variables in standalone code,
  25.     as per Technote #256. However, they have been modified here to allocate
  26.     the buffer space from a non-relocatable pointer rather than a relocatable
  27.     handle. The reason for this is because our globals will be used in our
  28.     INIT to hold a PPC parameter block. Our INIT will prime a PPCInform call,
  29.     and then exit. While the INIT is not executing and while the PPCInform
  30.     call is outstanding, we don't want our globals to move. Since our INIT
  31.     will be spending 99.9999999% of its time in this state, it doesn't made
  32.     sense to allocate our memory from a handle. And since the best place for a
  33.     block of memory that isn't going to be moving is low in the heap, we
  34.     allocate the block with NewPtr. 
  35. */
  36.  
  37. long A5Size (void);
  38. /* prototype for routine in Runtime.o */
  39.  
  40. void A5Init (Ptr myA5);
  41. /* prototype for routine in Runtime.o */
  42.  
  43. pascal void MakeA5World (A5RefType *A5Ref) {
  44.     *A5Ref = NewPtr(A5Size());
  45.     if ((long)*A5Ref) {
  46.         A5Init((Ptr)( (long)*A5Ref + A5Size() - kAppParmsSize));
  47.     }
  48. }
  49.  
  50. pascal long SetA5World (A5RefType A5Ref) {
  51.     return SetA5( (long)A5Ref + A5Size() - kAppParmsSize);
  52. }
  53.  
  54. pascal void DisposeA5World (A5RefType A5Ref) {
  55.     DisposePtr((Ptr)A5Ref);
  56. }
  57.